package com.ksyun.cloudhostalarmprocessing.common;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author zyl
 * @create
 * @discription
 */
@Data
@NoArgsConstructor
public class ResultSet<T> {
    Integer code;
    String message;
    T data;


    /**
     *    访问成功，没有数据返回，只返回成功的状态
     * @return
     */
    public static ResultSet ok(){
        ResultSet result = new ResultSet();
        result.setCode(200);
        result.setMessage("成功啦");
        return result;
    }
    /***
     * 自定义返回成功的所有数据
     */
    public static<T> ResultSet ok(T data){
        ResultSet<T> result = new ResultSet<T>();
        result.setCode(200);
        result.setMessage("成功啦");
        result.setData(data);
        return result;
    }
    /***
     * 返回失败
     */
    public static ResultSet fail(String msg){
        ResultSet result = new ResultSet();
        //失败code 300
        result.setCode(300);
        result.setMessage(msg);
        return result;
    }
}
